package com.yaorange.guild.user.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yaorange.guild.user.entity.BsMember;
import com.yaorange.guild.user.mapper.BsMemberMapper;
import com.yaorange.guild.user.service.BsMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BsMemberServiceImpl implements BsMemberService {

    @Autowired
    private BsMemberMapper bsMemberMapper;

    @Override
    public List<BsMember> selectAll(BsMember bsMember) {
        return bsMemberMapper.selectAll(bsMember);
    }

    @Override
    public PageInfo<BsMember> selectPage(Integer pageNum, Integer pageSize, BsMember bsMember) {
        if (pageNum == null || pageSize == null) {
            return new PageInfo<>(selectAll(bsMember));
        }
        PageHelper.startPage(pageNum, pageSize);
        List<BsMember> list = bsMemberMapper.selectPage( bsMember);
        return new PageInfo<>(list);
    }

    @Override
    public BsMember selectById(Long id) {
        return bsMemberMapper.selectById(id);
    }

    @Override
    public int insert(BsMember bsMember) {
        return bsMemberMapper.insert(bsMember);
    }

    @Override
    public int updateById(BsMember bsMember) {
        return bsMemberMapper.updateById(bsMember);
    }

    @Override
    public int deleteById(Long id) {
        return bsMemberMapper.deleteById(id);
    }
}
